<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-07-30 20:02:30
 * @LastEditTime: 2020-02-28 11:25:38
 * @LastEditors: Please set LastEditors
 -->
<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../css/vant.css">
    <link rel="stylesheet" type="text/css" href="../css/base.css" />
    <link rel="stylesheet" type="text/css" href="../css/local.css" />
    <!-- <link rel="stylesheet" type="text/css" href="../css/elementui.css" /> -->
    <link rel="stylesheet" href="../script/elementui/lib/theme-chalk/index.css?t=1">
    <link href="../script/elementui/vue-element-table.css" rel="stylesheet" />
    <script type="text/javascript" src="../script/vue.min.js"></script>
    <script type="text/javascript" src="../script/vant.min.js"></script>
    <script type="text/javascript" src="../script/base.js"></script>
    <script type="text/javascript" src="../script/elementui.js"></script>
    <script type="text/javascript" src="../script/jquery.js"></script>
    <script type="text/javascript" src="../script/jquery.signalR-2.4.1.min.js"></script>
    <script type="text/javascript" src="../script/ajaxFileUpload.js"></script>
    <script type="text/javascript" src="../script/layer/mobile/layer.js"></script>
    <script type="text/javascript" src="../script/signalr-mediate.js"></script>
    <style type="text/css">
        .content {
            padding: 10px;
        }

        .item {
            padding: 10px;
            display: flex;
            flex-wrap: wrap;
            background-color: #fff;
            border-radius: 8px;
            position: relative;
            margin: 2px 6px 10px 6px;
            width: 48%;

        }

        .van-field {
            width: 100%;
        }

        .van-field:nth-child(1) {
            width: 100%;
        }

        .van-field__label {
            margin-right: 8px;
            width: auto;
        }

        .number {
            text-align: center;
            margin-right: 8px;
            width: 2em;
            height: 2em;
            background-color: #1989fa;
            border-radius: 50%;
            color: #fff;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .value {
            text-align: left;
            color: #4A4A4A;
            font-weight: 500;
            font-size: 18px;
        }

        .van-cell {
            background-color: transparent;
        }

        .content .item1 {
            background-color: #b3d8ff;
        }

        .content .item0 {
            background-color: #c2e7b0;
        }

        .content .item-2 {
            background-color: #FFA500;
        }

        .content .item-1 {
            background-color: #f85757;
        }

        .content .item3 {
            background-color: #7FFFD4;
        }

        .content .item5 {
            background-color: #ddc0db;
        }

        .content .item-5 {
            background-color: #f85757;
        }

        .head {
            height: 30px;
            line-height: 16px;
            font-size: 14px;
            width: 100%;
            padding: 7px 20px;
            display: flex;
            justify-content: space-between;
        }

        .pointColor {
            /* width: 100px; */
            display: flex;
            margin-right: 10px;
        }

        .point {
            width: 14px;
            height: 14px;
            margin-right: 4px;
        }

        .img {
            position: absolute;
            width: 140px;
            height: 70px;
            right: 30px;
            top: 10px;
        }

        .img>img {
            width: 100%;
            height: 100%;
        }

        .chongdian .van-field__label {

            font-weight: bolder;

        }

        .bottomBtn {
            height: 50px;
            width: 100%;
            display: flex;
            align-items: center;
        }

        .bottomBtn .van-button {
            flex: 1;
        }

        .field_div {
            border-bottom: 1px solid #eee;
            width: 100%;
            display: flex;
            align-items: center;
            padding: 3% 0;
            margin: 0 4.2%;
        }

        .field_div1 {
            width: 90px;
            text-align: right;
        }

        .field_div div {
            color: #726465;
            font-size: 14px;
        }

        .field_div input {
            flex: 1;
            /* background-color: #f85757; */
            border: none;
            font-weight: 600;
            font-size: 15px;
            padding: 0;
            margin: 0;
        }


        .headDiv {
            display: flex;
            justify-content: space-between;
            align-items: center;
            width: 370px;
        }

        .headDiv>.van-button {
            width: 90px;
        }

        .headDiv2 {
            display: flex;
            align-items: center;
            padding: 5px;
        }

        .headDiv2 .el-date-picker {
            margin: 0 10px
        }

        .headDiv2 .el-select {
            margin: 0 10px
        }

        .headDiv2 .van-button {
            margin: 0 10px
        }

        .contentDiv {
            display: flex;
            flex-wrap: wrap;

        }

        .contentDivchild1 {
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .contentDivchild1 .Divchild {
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .Operator {
            width: 80%;
            /* background-color: red; */
        }

        .van-tag {
            color: #0283ef;
            background: rgba(2, 131, 239, 0.1);
            margin-right: 3px;
            padding: 2px;
            
        
        }


        .van_uploader {
            padding-top: 0;
            padding-bottom: 0;
            margin: 0;
            margin-top: 5px;
            display: flex;
            align-items: center;
            height: 60px;
            /* background-color: yellowgreen; */
        }


        .van-uploader_Div {
            width: 55px;
            height: 55px;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <div class="box">
            <van-nav-bar id="safeTop" v-if='name=="充电"' :title=" name + '列表' + '('  + title  +     CS + ')'" left-arrow
                @click-left="onClickLeft">

            </van-nav-bar>
            <van-nav-bar id="safeTop" v-else :title=" name + '列表'  + '('   + CS + ')' " left-arrow
                @click-left="onClickLeft">

            </van-nav-bar>
            <div class="head">
                <div style="width:450px;display: flex;align-items: center;">
                    <div class="pointColor" v-for="item in headList">
                        <div class="point" :style="{backgroundColor: item.color}"></div>
                        <div class="colorName">{{item.name}}</div>
                    </div>
                </div>
                <div v-if='name=="充电"' class="headDiv">
                    <van-button color="#7232dd" size="small" @click='changeTime'>展示时间</van-button>
                    <!-- <van-button type="primary" size="small" @click='changeSType(1)'>充电</van-button> -->
                    <!-- <van-button type="warning" size="small" @click='changeSType(2)'>抽酸</van-button> -->
                    <!-- <van-button type="info" size="small" @click='changeSType(3)'>下架</van-button> -->
                    <van-button type="primary" size="small" @click='changeSType(1)'>未充电</van-button>
                    <van-button type="warning" size="small" @click='changeSType(4)'>充电中</van-button>
                    <van-button style="background-color: #c491bf;border: none;color: #fff;" size="small"
                        @click='changeSType(5)'>已充电
                    </van-button>
                </div>
            </div>

            <div class="headDiv2">
                <el-date-picker v-model="StartDate" type="date" placeholder="开始时间" readonly @focus='datePicker("开始")'>
                </el-date-picker>
                <el-date-picker v-model="EndDate" type="date" placeholder="结束时间" readonly @focus='datePicker("结束")'>
                </el-date-picker>

                <el-select v-model="optionsvalue" placeholder="请选择" @change='changeValue'
                    v-if="api.pageParam.name == '下架'">
                    <el-option v-for="item in options1" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>

                </el-select>
                <el-select v-model="optionsvalue" placeholder="请选择" @change='changeValue'
                    v-if="api.pageParam.name == '抽酸'">
                    <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>

                </el-select>
                <van-button type="primary " size="small" style="width: 80px;" @click='getDataList("搜索")'>搜索</van-button>
            

            </div>

            <div class="content" v-if='name=="充电"'>
                <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
                    <div class="contentDiv">
                        <div class="item" :class="'item' + item.status" v-for="(item, index) in tableData">

                            <div class="van-cell van-field contentDivchild1">
                                <div class="Divchild">
                                    <div class="van-cell__title van-field__label number">
                                        <span>{{index + 1}}</span>
                                    </div>
                                    <span>{{item.ProductNameTime||item.ProductSpec}}</span>
                                </div>
                                <div>{{item.MF}}</div>
                            </div>

                            <van-field v-model="item.JNo" label="上架号:" readonly>
                            </van-field>


                            <van-field v-show='changeTimeShow' v-model="item.GSStartDate" label="开始时间:" readonly>
                            </van-field>
                            <van-field v-show='changeTimeShow' v-model="item.GSSEndDate" label="结束时间:" readonly>
                            </van-field>
                            <van-field v-show='SType==1' v-model="item.Mes" label="消息:" readonly>
                            </van-field>
                            <!-- <van-field v-show='SType==4' v-model="item.CSDate" label="开始时间:" readonly>
                            </van-field> -->
                            <!-- <van-field v-show='SType==4' v-model="item.DDTime" label="结束时间:" readonly>
                            </van-field> -->

                            <!-- <van-field v-show='SType==4' v-model="item.CSDate" label="开始时间:" readonly>
                            </van-field> -->
                            <!-- <van-field v-show='SType==4' v-model="item.DDTime" label="结束时间:" readonly>
                            </van-field> -->
                            <van-field v-show='SType==4||SType==5' v-model="item.KJDate" label="开机时间:" readonly>
                            </van-field>

                        </div>
                    </div>
                </van-list>
            </div>

            <div class="content" v-else>
                <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
                    <div class="contentDiv">
                        <div class="item" :class="'item' + item.status" v-for="(item, index) in tableData">
                            <div class="img" v-show="item.status1 == 1">
                                <img src="../image/xiajia.png" v-show="name == '下架'" alt="">
                                <img src="../image/chousuan.png" v-show="name == '抽酸'" alt="">
                            </div>

                            <div class="van-cell van-field">
                                <div class="van-cell__title van-field__label number">
                                    <span>{{index + 1}}</span>
                                </div>
                                <div class="van-cell__value van-field__value value">{{item.ProductName}}</div>
                            </div>
                            <div class="field_div">
                                <div>上架层数：</div>
                                <input type="text" style="font-size: 18px;" :class="'item' + item.status"
                                    v-model="item.SJNo + '('+item.TimeContent + ')'" placeholder="请填写上架号" readonly
                                    v-if='item.TimeContent'></input>
                                <input type="text" style="font-size: 18px;" :class="'item' + item.status"
                                    v-model="item.SJNo" placeholder="请填写上架号" readonly v-else></input>
                            </div>

                            <van-field v-if='name=="抽酸"' v-model="item.Qty" label="抽酸数量：" placeholder="请填写抽酸数量"
                                readonly>
                            </van-field>
                            <van-field v-else v-model="item.Qty" label="下架数量：" placeholder="请填写下架数量" readonly>
                            </van-field>

                            <van-field v-model="item.KJDate" v-show='name=="抽酸"' label="开机时间：" placeholder="请填写开机时间"
                                readonly></van-field>

                            <div class="field_div" v-show='name=="抽酸"'>
                                <div>可抽酸时间:</div>
                                <input type="text" :class="'item' + item.status" v-model="item.CSYJDate"
                                    placeholder="请填写可抽酸时间" readonly></input>
                            </div>
                            <div class="field_div" v-show="name=='下架'">
                                <div>可下架时间：</div>
                                <input type="text" :class="'item' + item.status" v-model="item.GMYJDate"
                                    placeholder="请填写下架时间" readonly></input>
                            </div>


                            <div class="bottomBtn" v-show='name=="抽酸"'>
                                <div class="field_div">
                                    <div>开始抽酸时间:</div>
                                    <input type="text" :class="'item' + item.status" v-model="item.CSDate"
                                        placeholder="请填写开始抽酸时间" readonly />
                                </div>

                                <div class="field_div1" v-show="name=='抽酸'&&!item.CSDate">
                                    <van-button :disabled="item.status==1" size="small"
                                        style="background-color: #FF41FF;border: none;"
                                        @click='handlerAdd(item,index,"开始抽酸")'>开始抽酸
                                    </van-button>
                                </div>
                            </div>
                            <div class="bottomBtn" v-show='name=="抽酸"'>
                                <div class="field_div">
                                    <div>结束抽酸时间:</div>
                                    <input type="text" :class="'item' + item.status" v-model="item.DDTime"
                                        placeholder="请填写结束抽酸时间" readonly />
                                </div>
                                <div class="field_div1" v-show="name=='抽酸'&&!item.DDTime">
                                    <van-button size="small" :disabled="item.status==1"
                                        style="background-color: #FF41FF;border: none;"
                                        @click='handlerEnd(item,index,"结束抽酸")'>结束抽酸
                                    </van-button>
                                </div>

                            </div>
                            <div class="bottomBtn" v-show="name=='下架'">
                                <div class="field_div">
                                    <div>下架时间：</div>
                                    <input type="text" :class="'item' + item.status" v-model="item.GMDate"
                                        placeholder="填写下架时间" readonly />
                                </div>
                                <div class="field_div1" v-show="name=='下架'&&!item.GMDate&&isClick==true">
                                    <!-- <van-button size="small" :disabled="item.status==1" -->
                                    <van-button :disabled="item.status==1" size="small"
                                        style="background-color: #FF41FF;border: none;" @click='handlerAdd(item,index)'>
                                        确定下架
                                    </van-button>
                                </div>
                            </div>

                            <div class="van_uploaderDiv" v-show="name=='下架'">
                                <van-field name="uploader" readonly class="van_uploader" label="请选择照片：">
                                    <template #input>
                                        <div class="van-uploader">
                                            <!-- 整行图片 -->
                                            <div class="van-uploader__wrapper">
                                                <!-- 单个照片 -->
                                                <div class="van-uploader__preview" v-for="(ite, idx) in item.imgList">
                                                    <van-image @click="previewImg(index)" width="55" height="55"
                                                        :src="serverIP + ite.url">
                                                    </van-image>
                                                    <div @click="deleteImg(index,idx)"
                                                        class="van-uploader__preview-delete van_deleteDiv">
                                                        <i
                                                            class="van-icon van-icon-cross van-uploader__preview-delete-icon  van_uploaderi"></i>
                                                    </div>
                                                </div>
                                                <!-- 上传图片的按钮 -->
                                                <!-- <div v-show="item.imgList.length < 1" -->
                                                <div v-show="item.imgList.length < 1"
                                                    class="van-uploader__upload van-uploader_Div"
                                                    @change="uploadNewFile(index)">
                                                    <i
                                                        class="van-badge__wrapper van-icon van-icon-photograph van-uploader__upload-icon"></i>
                                                    <input type="file" ref="selectFiles" :name="'newFile'+index"
                                                        :id="'newFile'+index" accept="image/*"
                                                        class="van-uploader__input" capture="user">
                                                </div>
                                            </div>
                                        </div>
                                    </template>
                                </van-field>
                            </div>

                        </div>
                    </div>



                </van-list>
            </div>

            <van-popup v-model="datePickerShow" position="bottom">
                <van-datetime-picker v-model="currentDate" type="date" title="选择操作日期" @confirm="onConfirm"
                    @cancel="datePickerShow = false"></van-datetime-picker>
            </van-popup>
            <audio id="audioPlayer" preload="auto">
                <source src="../image/aigei_com.mp3" type="audio/mpeg">
            </audio>

            <div class="indexBottom">
                汇智云创 技术支持
            </div>


            <van-dialog v-model="dialogShow" title="提示: 是否确认提交！" show-cancel-button @confirm='dialogConfirm'
                @cancel='dialogCancel'>
                <!-- <van-field v-model="dialogtitle" label="作业员" placeholder="作业员" is-link readonly @click="handlerSJNo()"> -->

                <div class="van-cell van-field">
                    <div class="van-cell__title van-field__label">
                        <span>作业员</span>
                    </div>
                    <div class="Operator" @click="handlerSJNo">
                        <span @click='closeTag($event,index)' class="van-tag van-tag--info"
                            v-for="(item, index) in dialogtitle">
                            {{ item }}
                            <i class="van-icon van-icon-clear"></i>
                        </span>
                    </div>
                </div>

            </van-dialog>
            <van-action-sheet v-model="SJQtyShow" :actions="SJQtyActions" @select="onSelectSJQty">
            </van-action-sheet>






        </div>
    </div>
</body>

<script type="text/javascript">
    var vm;

    apiready = function () {
        var photoBrowser = api.require('photoBrowser');

        api.addEventListener({
            name: 'refreshExtraAcidList'
        }, function (ret) {
            vm.pageIndex = 1
            vm.tableData = []
            vm.getDataList()
        })
        api.addEventListener({
            name: 'getCDAlarmLList'
        }, function (ret) {
            APP.getCDAlarmLList()
        })
        api.addEventListener({
            name: 'getYCKBDataLiist'
        }, function (ret) {
            APP.getYCKBDataLiist()
        })
        vm = new Vue({
            el: '#app',
            data: {
                currentDate: new Date(),
                selectFilesShow: false,
                serverIP: '',
                confirmObj: {},
                dialogShow: false,
                dialogtitle: [],
                SJQtyIndex: '',
                SJQtyShow: false,
                SJQtyActions: [],
                CS: '',
                isClick: true,
                changeTimeShow: false,
           
                datePickerShow: false,
                datePickerTitle: '',
                options1: [
                    {
                        value: 1,
                        label: '已下架'
                    },
                    {
                        value: -1,
                        label: '未下架'

                    }

                ],
                options: [
                    {
                        value: 1,
                        label: '已抽酸'
                    },
                    {
                        value: -1,
                        label: '未抽酸'

                    },
                    {
                        value: 0,
                        label: '抽酸中'

                    }
                ],
                StartDate: '',
                EndDate: '',
                optionsvalue: -1,
                name: api.pageParam.name,
                tableData: [],
                tableDataLength: 0,
                loading: false,
                finished: false,
                pageIndex: 1,
                pageSize: 30,
                SType: 1,
                title: '',
                headList: [
                    {
                        color: '#c2e7b0',
                        name: '正常'
                    },
                    {
                        color: '#b3d8ff',
                        name: '未到时间'
                    },
                    {
                        color: '#FFA500',
                        name: '马上超时'
                    },
                    {
                        color: '#f85757',
                        name: '超时'
                    },
                    {
                        color: api.pageParam.name == '下架' ? '' : '#7FFFD4',
                        name: api.pageParam.name == '下架' ? '' : api.pageParam.name == '抽酸' ? '抽酸中' : '充电中'
                    },
                    {
                        color: api.pageParam.name == '充电' ? '#ddc0db' : '',
                        name: api.pageParam.name == '充电' ? '已充电' : ''
                    },
                ]
            },
            created: function () {
                var that = this;
                that.serverIP = 'http://' + APP.serverIP

                window.localStorage.setItem('pageName', JSON.stringify(that.name))
                var nowTime = APP.getFormatDate(new Date()).split(' ')[0]
                that.CS = JSON.parse(window.localStorage.getItem('userInfo')).className
                if (that.name == '充电') {
                    that.StartDate = nowTime
                } else {
                    that.StartDate = APP.getFormatbeforDate()
                }
                that.EndDate = nowTime
                that.getDataList()

                setInterval(() => {
                    that.getDataList('循环')
                }, 60000);


                if (that.name == '抽酸') {
                    that.dialogtitle = JSON.parse(window.localStorage.getItem('Job1')) || []
                }
                else if (that.name == '下架') {
                    that.dialogtitle = JSON.parse(window.localStorage.getItem('Job2')) || []
                }
                // else { // 充电
                //     that.dialogtitle = JSON.parse(window.localStorage.getItem('Job3')) || []
                // }


            },
            mounted() {
                var that = this;
                APP.setSafeTop()
                // that.title = that.SType == 1 ? '充电' : that.SType == 2 ? '抽酸' : '下架'
                that.title = that.SType == 1 ? '未充电' : '充电中'

            },
            methods: {
                uploadNewFile(index) {
                    var that = this
                    var url = that.serverIP + '/Frame/uploadImgFile?dirName=下架列表';
                    $.ajaxFileUpload({
                        type: 'POST',
                        url: url,
                        secureuri: false,
                        fileElementId: 'newFile' + index,
                        dataType: 'json',
                        success: function (res, status) {
                            if (res.status == 200) {
                                console.log(JSON.stringify(res.data.origin))
                                that.tableData[index].imgList.push({ url: res.data.origin })
                                if (that.name == '下架' && that.selectFilesShow) {
                                    var val = that.confirmObj.val
                                    var confirmObjindex = that.confirmObj.index
                                    that.tableData[confirmObjindex].GMDate = APP.getFormatDate(new Date())
                                    that.selectFilesShow = false
                                    that.confirm(val, index)
                                }
                                else {
                                    console.log('ssssseeeeeeeeeeeeee');
                                    that.tableData[index].GMDate = ''
                                }
                            } else {
                                vm.$toast('上传失败');
                            }
                        },
                        error: function (data, status, e) {
                            console.log('失败data', JSON.stringify(data))
                        }

                    });

                },
                deleteImg(index, idx) {
                    var that = this
                    that.tableData[index].imgList.splice(idx, 1)
                },
                previewImg(index) {
                    var that = this
                    document.activeElement.blur();
                    var imgFlag = 0
                    var imageArr = []
                    that.tableData[index].imgList.map((item) => {
                        imageArr.push(that.serverIP + item.url)
                    })
                    photoBrowser.open({
                        images: imageArr,
                        bgColor: '#000'
                    }, function (ret, err) {
                        if (ret) {
                            // alert(JSON.stringify(ret));
                            if (ret.eventType == 'show') {
                                imgFlag = 1
                            }
                            if (ret.eventType == 'click') {
                                imgFlag = 0
                                photoBrowser.close();
                            }
                        } else {
                            layer.open({
                                content: '图片打开失败，请重试！',
                                skin: 'msg',
                                time: 2
                            });
                        }
                    });
                },


                closeTag(event, index) {
                    var that = this
                    event.stopPropagation();
                    that.dialogtitle.splice(index, 1)
                    vm.$forceUpdate()

                },
                dialogConfirm() {
                    var that = this
                    if (that.dialogtitle.length > 0) {
                        if (that.name == '抽酸') {
                            window.localStorage.setItem('Job1', JSON.stringify(that.dialogtitle))
                        }
                        else if (that.name == '下架') {
                            window.localStorage.setItem('Job2', JSON.stringify(that.dialogtitle))
                        }
                        // else { // 充电
                        //     window.localStorage.setItem('Job3', JSON.stringify(that.dialogtitle))
                        // }
                        var val = that.confirmObj.val
                        var index = that.confirmObj.index
                        if (that.name == '下架') {
                            // that.tableData[index].GMDate = APP.getFormatDate(new Date())
                            if (that.tableData[index].imgList.length > 0) {
                                console.log('已经存在');
                                that.confirm(val, index)

                            } else {
                                that.selectFilesShow = true
                                that.$refs.selectFiles[index].click(); // 触发文件输入的点击事件
                            }

                        } else {
                            that.tableData[index].DDTime = APP.getFormatDate(new Date())
                            that.confirm(val, index)
                        }
                    }
                    else {
                        api.toast({
                            msg: '请选择作业员'
                        })
                    }

                },
                dialogCancel() {
                    var that = this
                    api.toast({
                        msg: '提交已取消!'
                    })
                },
                onSelectSJQty(val) {
                    var that = this
                    console.log(JSON.stringify(val))
                    // that.dialogtitle.push(val.name)

                    if (that.dialogtitle.findIndex(item => { return item == val.name }) == -1) {
                        that.dialogtitle.push(val.name)
                        that.SJQtyShow = false
                    } else {
                        api.toast({
                            msg: '已选择该人员，请勿重复选择！'
                        })
                    }
                    console.log(JSON.stringify(that.dialogtitle))
                },
                handlerSJNo() {
                    var that = this
                    that.SJQtyShow = true
                    console.log(JSON.stringify(that.name))
                    APP.ajax('getCDJobs', { Type: that.name }, function (res) {
                        res.ds.map(item => item.name = item.Name)
                        console.log('getCDJobs' + JSON.stringify(res.ds))
                        that.SJQtyActions = res.ds
                    })
                },
                changeValue(val) {
                    var that = this
                    // that.loading = false
                    // that.finished = false
                    console.log(val)
                },
                changeTime() {
                    var that = this
                    that.changeTimeShow = !that.changeTimeShow
                },
                datePicker(val) {
                    var that = this
                    that.datePickerShow = true
                    that.datePickerTitle = val
                },
                onConfirm(date) {
                    var that = this
                    that.datePickerShow = false;
                    
                    var DateTime = APP.getFormatDate(that.currentDate).split(' ')[0]
                    if (that.datePickerTitle == '开始') {
                        that.StartDate = DateTime;
                    } else {
                        that.EndDate = DateTime;
                    }

                },
                changeSType(val) {
                    var that = this
                    that.SType = val
                    that.changeTimeShow = false
                    that.tableData = []
                    that.pageIndex = 1
                    that.finished = false
                    // that.title = that.SType == 1 ? '充电' : that.SType == 2 ? '抽酸' : '下架'
                    // that.title = that.SType == 1 ? '未充电' : '充电中'
                    that.title = that.SType == 1 ? '未充电' : that.SType == 4 ? '未充电' : '已充电'

                    var nowTime =  APP.getFormatDate(new Date()).split(' ')[0]

                    if (val == 5) {

                        that.StartDate = APP.getFormatbeforDate()
                        
                    }
                    else {
                        that.StartDate = nowTime
                    }
                    that.getDataList()

                },
                onClickLeft() {
                    var that = this
                    api.closeWin()
                    api.sendEvent({
                        name: 'refreshIndexList'
                    })
                },
                onLoad() {
                    var that = this
                    that.pageIndex++
                    console.log('执行')
                    that.getDataList()
                },
                getDataList(val) {
                    var that = this
                    var cmd
                    var obj
                    if (val == '搜索') {
                        that.finished = false
                        that.pageIndex = 1
                        that.tableData = []
                    } else if (val == '循环') {
                        that.finished = false
                        that.tableData.splice(that.tableData.length + 1 - that.tableDataLength)
                        that.tableData.pop(that.tableDataLength)
                    }
                    var StartDateTime = that.StartDate
                    var EndDateTime = that.EndDate
                    that.loading = true
                    if (that.name == '抽酸') {
                        cmd = 'getCSRecords'
                    }
                    else if (that.name == '下架') {
                        cmd = 'getGMRecords'
                    }
                    else {
                        // 充电
                        cmd = 'getCDRecords'
                    }

                    var CJ = JSON.parse(window.localStorage.getItem('userInfo')).classID

                    if (cmd == 'getCDRecords') {

                        obj = {
                            pageIndex: that.pageIndex,
                            pageSize: that.pageSize,
                            SType: that.SType,
                            StartDate: StartDateTime,
                            EndDate: EndDateTime,
                            CJ: CJ
                        }
                        // obj = {
                        //     pageIndex: that.pageIndex,
                        //     pageSize: that.pageSize,
                        //     SType: that.SType,
                        //     CJ: CJ
                        // }
                    }
                    else {
                        obj = {
                            pageIndex: that.pageIndex,
                            pageSize: that.pageSize,
                            StartDate: StartDateTime,
                            EndDate: EndDateTime,
                            status1: that.optionsvalue,
                            CJ: CJ

                        }
                    }
                    console.log('optionsvalue', JSON.stringify(obj))
                    APP.ajax(cmd, obj, function (res) {
                        console.log('res', JSON.stringify(res))
                        that.tableDataLength = res.ds.length
                        res.ds.map((item) => {
                            if (item.Filepaths && item.Filepaths != 'null') {
                                item.imgList = []
                                item.imgList.push({ url: item.Filepaths })

                            } else {
                                item.imgList = []
                            }
                            item.GSStartDate = item.GSStartDate.replace('T', ' ')
                            if (cmd == 'getCDRecords') {
                                if (that.name == '充电') {
                                    item.status = item.status1
                                    if (that.SType == 4) {
                                        item.status = 3
                                    }
                                    else if (that.SType == 5) {
                                        item.status = 5
                                    }
                                    if (that.SType == 5 && item.Status == - 5) {
                                        item.status = -5
                                    }
                                    if (that.SType == 4 && item.Status == - 5) {
                                        item.status = -5
                                    }
                                } else {
                                    console.log('充电列表', JSON.stringify(item.status1))
                                    if (item.status1 == 1000) {
                                        if (item.status2 == 1) {
                                            item.status = 0
                                        }
                                        else if (item.status2 == 0) {
                                            item.status = 1
                                        }
                                        else if (item.status2 == -1) {
                                            item.status = -1
                                        }
                                        else if (item.status2 == -2) {
                                            item.status = -2
                                        }
                                    }
                                    else if (item.status2 == 2000) {
                                        if (item.status1 == 1) {
                                            item.status = 0
                                        }
                                        else if (item.status1 == 0) {
                                            item.status = 1
                                        }
                                        else if (item.status1 == -1) {
                                            item.status = -1
                                        }
                                        else if (item.status1 == -2) {
                                            item.status = -2
                                        }
                                    }
                                }
                            }
                            else {
                                item.status = item.status1 == 1 ? '' : item.status
                                if (that.optionsvalue == 0 && item.status1 == 0) {
                                    item.status = 3
                                }
                            }
                        })
                        that.tableData.push(...res.ds)

                        // that.tableData = res.ds
                        setTimeout(() => {
                            that.isClick = true
                        }, 10000);
                        that.loading = false
                        if (res.ds.length < that.pageSize) {
                            that.finished = true
                        }
                    })

                },


                handlerEnd(val, index, title) {
                    var that = this
                    var CSDate = that.tableData[index].CSDate
                    if (CSDate) {
                        that.dialogShow = true
                        that.confirmObj = {
                            val,
                            index
                        }
                        // api.confirm({
                        //     title: '提示',
                        //     msg: '是否确认提交！',
                        //     buttons: ['确定', '取消']
                        // }, function (ret, err) {
                        //     if (ret.buttonIndex == 1) {
                        //         that.tableData[index].DDTime = APP.getFormatDate(new Date())
                        //         that.confirm(val, index, title)
                        //     }
                        //     else {
                        //         api.toast({
                        //             msg: '提交已取消!'
                        //         })

                        //     }
                        // });
                    }
                    else {
                        api.confirm({
                            title: '提示',
                            msg: '请输入开始抽酸时间！',
                            buttons: ['确定', '取消']
                        }, function (ret, err) {
                            if (ret.buttonIndex == 1) {
                            }
                        });
                    }
                },

                handlerAdd(val, index) {
                    var that = this
                    if (that.name == '抽酸') {
                        that.tableData[index].CSDate = APP.getFormatDate(new Date())
                        that.confirm(val, index)
                    }
                    else {
                        that.confirmObj = {
                            val,
                            index
                        }
                        that.dialogShow = true
                    }

                },
                confirm(val, index) {
                    var that = this
                    var obj, cmd
                    if (that.name == '抽酸') {
                        cmd = 'saveCSRecord'
                        obj = {
                            MonitorID: val.MonitorID,
                            CSDate: that.tableData[index].CSDate ? that.tableData[index].CSDate : '',
                            CSEndDate: that.tableData[index].DDTime ? that.tableData[index].DDTime : '',
                            GSID: that.tableData[index].GSID,
                            SJNo: val.SJNo1,
                            CSG: that.dialogtitle.join(',')
                        }
                    }
                    else {
                        cmd = 'saveGMRecord'
                        obj = {
                            MonitorID: val.MonitorID,
                            GMDate: that.tableData[index].GMDate ? that.tableData[index].GMDate : '',
                            GSID: that.tableData[index].GSID,
                            SJNo: val.SJNo1,
                            XJG: that.dialogtitle.join(','),
                            FilePath: that.tableData[index].imgList.map(item => item.url).join(',')
                        }
                    }

                    console.log('180obj', JSON.stringify(obj))
                    APP.ajax(cmd, obj, function (res) {
                        console.log('res', JSON.stringify(res))
                        api.toast({
                            msg: '提交成功！'
                        })
                        that.isClick = false
                        that.pageIndex = 1
                        that.tableData = []
                        that.getDataList()
                        api.sendEvent({
                            name: 'refreshIndexList'
                        })

                    })


                    // return
                    // APP.ajax('IfAlarm', {
                    //     GSID: that.tableData[index].GSID,
                    //     SJNo: val.SJNo1
                    // }, function (data) {
                    //     console.log(JSON.stringify(data))
                    //     if (data.ds[0].MonitorID) {
                    //         alert('有未处理的报警，请先处理后再操作')
                    //         if (that.name == '抽酸') {
                    //             that.tableData[index].CSDate = ''
                    //             that.tableData[index].DDTime = ''
                    //         } else {
                    //             that.tableData[index].GMDate = ''

                    //         }
                    //     } else {
                    //         if (that.name == '抽酸') {
                    //             cmd = 'saveCSRecord'
                    //             obj = {
                    //                 MonitorID: val.MonitorID,
                    //                 CSDate: that.tableData[index].CSDate ? that.tableData[index].CSDate : '',
                    //                 CSEndDate: that.tableData[index].DDTime ? that.tableData[index].DDTime : '',
                    //                 GSID: that.tableData[index].GSID,
                    //                 SJNo: val.SJNo1
                    //             }
                    //         }
                    //         else {
                    //             cmd = 'saveGMRecord'
                    //             obj = {
                    //                 MonitorID: val.MonitorID,
                    //                 GMDate: that.tableData[index].GMDate ? that.tableData[index].GMDate : '',
                    //                 GSID: that.tableData[index].GSID,
                    //                 SJNo: val.SJNo1
                    //             }
                    //         }

                    //         console.log('180obj', JSON.stringify(obj))
                    //         APP.ajax(cmd, obj, function (res) {
                    //             console.log('res', JSON.stringify(res))
                    //             api.toast({
                    //                 msg: '提交成功！'
                    //             })
                    //             that.isClick = false
                    //             that.pageIndex = 1
                    //             that.tableData = []
                    //             that.getDataList()
                    //             // window.location.reload();  
                    //             api.sendEvent({
                    //                 name: 'refreshIndexList'
                    //             })

                    //         })

                    //     }

                    // })

                },


            }
        })
    };
</script>

</html>